﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dal.Iterfease;
using Model;
using Model.viewModel;

namespace xiaomiApi.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class OrderController : ControllerBase
    {
        private readonly IOrderDal _userDal;

        public OrderController(IOrderDal userDal)
        {
            _userDal = userDal;
        }

        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="ord"></param>
        /// <returns></returns>
        [HttpPost, Route("AddOrder")]
        public IActionResult AddOrder(OrderModel ord)
        {
            var onumber = "";
            var sql = _userDal.AddOrder(ord,out onumber);
            return Ok(new { onumber, sql });
        }

        /// <summary>
        /// 确认订单
        /// </summary>
        /// <param name="onumber"></param>
        /// <returns></returns>
        [HttpGet, Route("showPayment")]
        public IActionResult showPayment(string onumber)
        {
            return Ok(_userDal.showPayment(onumber));
        }


    }
}
